Import('env')
import os
sources = Split("""
    md5.c
    sha.c
    sha256.c
    aes.c
    hexdigest.c
""")


env.StaticLibrary(target = 'ucipher', source = sources)
if not os.path.exists("mucipher.i"):
    open(str("mucipher.i"), "w").write(open(os.path.abspath("../../Mucipher/mucipher.i")).read())
if not os.path.exists("wraphelp.c"):
    open(str("wraphelp.c"), "w").write(open(os.path.abspath("../../Mucipher/wraphelp.c")).read())

if "PYMUCIPHER" in env.__dict__ and env['PYMUCIPHER']:
	if 'swig' in env['TOOLS']:
		import os
		SConscript(os.path.join('python', 'SConscript'))
		print "SWIG found, building Python bindings for mucipher."
		print "If you get an error like: No such file or directory: 'mucipher.i'"
		print "Disable with: PYMUCIPHER=0"
	else:
		print "WARNING: SWIG not found , NOT building Python bindings for mucipher."
else:
	print "WARNING: PyMucipher disabled, NOT building Python bindings for mucipher."
	print "Enable with: PYMUCIPHER=0"
	print "Looking for replacement (PyCrypto)..."
	try:
		import Crypto
	except Exception, error:
		print "PyCrypto is not available, maybe you should install it?:", error
	else:
		print "PyCrypto is available, PyMucipher isn't needed anyway."
	
#SConscript(os.path.join('perl', 'SConscript'))
#can't use perl, cstring not implemented in swig-perl
print